package com.hong.springcloud.controller;

import com.hong.springcloud.entity.Product;
import com.hong.springcloud.service.ProductClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created by John on 2018/11/25.
 */
@RestController
public class ProductConsumerController {

    @Autowired
    private ProductClientService productService;

    @RequestMapping(value = "/consumer/product/add", method = RequestMethod.POST)
    public Integer add(Product product)
    {
        return productService.add(product);
    }

    @RequestMapping(value = "/consumer/product/get/{id}",method = RequestMethod.GET)
    public Product get(@PathVariable("id") Long id)
    {
        return productService.get(id);
    }

    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/consumer/product/list",method = RequestMethod.GET)
    public Map<String,Object> list()
    {
        return productService.list();
    }

}
